package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;

import com.bjesc_b2c.app.appraiset.R;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.SelectCarBrandBean;

/**
 * Created by Jason Chen on 2017/2/22.
 * 品牌列表adapter
 */

public class SelectCarBrandAdapter extends CommonAdapter<SelectCarBrandBean> {
;
    public SelectCarBrandAdapter(Context context, int layoutId, List<SelectCarBrandBean> datas) {
        super(context, layoutId, datas);
    }
    @Override
    protected void convertView(ViewHolder holder, SelectCarBrandBean bean, int position) {

           holder.setText(R.id.tv_car_brand_name, bean.getName());
           if (bean.isCheck()) {   //设置选中效果
               holder.setBackgroundRes(R.id.tv_car_brand_name, R.color.colorFFF1F1F1);
           } else {
               holder.setBackgroundRes(R.id.tv_car_brand_name, R.color.colorWhite);
           }
           if (position != 0) {
               if (mDatas.get(position).getFirstLetter().equals(mDatas.get(position - 1).getFirstLetter())) {  //参数后一位与前一位字母相同
                   holder.setVisible(R.id.tv_letter, false);
               } else {
                   holder.setText(R.id.tv_letter, bean.getFirstLetter());
                   holder.setVisible(R.id.tv_letter, true);
               }
           } else {
               holder.setText(R.id.tv_letter, bean.getFirstLetter());
               holder.setVisible(R.id.tv_letter, true);
           }

    }

}
